<template>
	<view class="container">
		<uni-section title="食物图片" sub-title="" type="square">
			<image :src="'http://localhost:8090/foodapp/images/'+ data.icon" mode=""></image>
		</uni-section>

		<uni-section title="食物名称" sub-title="" type="square">
			{{data.name}}
		</uni-section>

		<uni-section title="食物类别" sub-title="" type="square">
			{{data.type}}
		</uni-section>

		<uni-section title="食物价格" sub-title="" type="square">
			{{data.price}}
		</uni-section>

		<uni-section title="食物介绍" sub-title="" type="square">
			{{data.label}}
		</uni-section>
		<view class="button">
			<button type="primary" @click="toaddcomment">查看评论</button>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: -1, // 食物id
				data: {}
			}
		},
		methods: {
			toaddcomment() {
				uni.navigateTo({
					url: '../addcomment/commentlist/commentlist?foodid='+this.data.id,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			}
		},
		onLoad(option) {
			// console.log(option); 传递的参数
			this.id = option.id

			// 加载网络数据：
			uni.request({
				url: 'http://localhost:8090/foodapp/food/findone',
				method: 'POST',
				data: {
					id: this.id,
				},
				success: res => {
					// console.log(res.data.data);
					this.data = res.data.data
				},
				fail: () => {},
				complete: () => {}
			});
		}
	}
</script>

<style>
	.container {
		padding: 10px;
		font-size: 14px;
		line-height: 24px;
	}

	.button {
		position: fixed;
		bottom: 0;
		width: 50%;
		right: 0px;
	}
</style>